package com.kelvin.backend.common.exception;

import com.kelvin.backend.common.web.response.BaseCode;
import com.kelvin.backend.common.web.response.CodeMsg;
import net.sf.jsqlparser.expression.StringValue;

/**
 * <p>Title: BaseException</p>
 * <p>Description: </p>
 *
 * @author Kelvin.Chen
 * @datetime 2021/7/9 16:42
 */
public class BaseException extends RuntimeException {

    protected String code;

    protected String msg;

    public BaseException() {
        super();

        this.code = BaseCode.ERROR.code();
        this.code = BaseCode.ERROR.msg();
    }

    public BaseException(CodeMsg codeMsg) {
        super();

        this.code = String.valueOf(codeMsg.code());
        this.code = codeMsg.msg();
    }

    public BaseException(String msg) {
        super(msg);
        this.code = BaseCode.ERROR.code();
        this.msg = msg;
    }

    public BaseException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BaseException(Exception e) {
        super(e);
        this.code = BaseCode.ERROR.code();
        this.msg = "系统异常，请联系管理员";
    }

    public BaseException(String msg, Exception e) {
        super(msg, e);
        this.code = BaseCode.ERROR.code();;
        this.msg = msg;
    }

    public BaseException(String msg, String code, Exception e) {
        super(msg, e);
        this.code = code;
        this.msg = msg;
    }

}
